﻿using System;

/* 生成一个100个元素的乱序数组包含0~99的每个数字且只出现一次 */
namespace Prictice9
{
    class Practice
    {
        static int[] getRandomArray(int size)
        {
            Random r = new Random();
            
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = i;
            }
            // 打乱
            for (int i = size - 1; i >= 0; i--)
            {
                int index = r.Next(i + 1);
                int temp = array[index];
                array[index] = array[i];
                array[i] = temp;
            }
            return array;
        }

        public static void Execute()
        {
            Console.Write("随机数组: ");
            int[] array = getRandomArray(100);
            string str = string.Join(" ", array);
            Console.WriteLine(str);
        }
    }
}